// @title           Web模块API
// @version         1.0
// @description     This is a sample server celler server.
// @termsOfService  http://swagger.io/terms/

// @contact.name   API Support
// @contact.url    http://www.swagger.io/support
// @contact.email  sage12345678@qq.com

// @license.name  Apache 2.0
// @license.url   http://www.apache.org/licenses/LICENSE-2.0.html

// @host      localhost:8080
// @BasePath  /
// @schemes http https
// @produce      json,html

// @securityDefinitions.basic   BasicAuth

// @securityDefinitions.apikey	ApiKeyAuth
// @in							header
// @name						Authorization
// @description					Api-Token, Header: Authorization

// @externalDocs.description  OpenAPI
// @externalDocs.url          https://swagger.io/resources/open-api/
package webapp

import (
	"gitee.com/captials-team/ubdframe/src/apps"
	"gitee.com/captials-team/ubdframe/src/common"
	"gitee.com/captials-team/ubdframe/src/domain/configstc"
	v1log "gitee.com/captials-team/ubdframe/src/pkg/logs"
	"go.uber.org/dig"
)

type App struct {
	*apps.App

	di        *dig.Container
	Conf      *configstc.WebAppConfig
	ApiServer *ApiServer
}

func NewApp(di *dig.Container, conf *configstc.WebAppConfig, logger v1log.ILog) *App {
	app := &App{
		di:   di,
		Conf: conf,
		App:  apps.NewApp(di, "web_app"),
	}
	common.ErrPanic(di.Provide(NewApiServer))

	common.ErrPanic(di.Invoke(func(api *ApiServer) {
		app.WithApiServer(api)
		app.ApiServer = api
	}))

	return app
}
